package com.shirotest.component;

import org.apache.catalina.connector.Connector;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Tomcat允许特殊字符访问
 */
@Configuration
public class TomcatConfigurer {
	@Bean
    public TomcatServletWebServerFactory webServerFactory() {
        TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
        factory.addConnectorCustomizers((Connector connector) -> {
            connector.setProperty("relaxedPathChars", "\"[\\]{|}");
            connector.setProperty("relaxedQueryChars", "\"[\\]{|}");
        });
        return factory;
    }
}
